<style lang="less">
  .customer-service-statistics {
    .grid-content {
      border: 1px solid #d1dbe5;
      border-radius: 4px;
      min-height: 155px;
      padding: 10px 10px 0px 10px;
    }
    .bg-purple {
      background: #f2f2f2;
      .el-row {
        margin-bottom: 5px;
      }
      .bg-purple-header {
        font-size: 16px;
      }
    }
    .statics {
      position: inherit;
      label {
        width: 80px;
        text-align: left;
        vertical-align: middle;
        float: left;
        line-height: 19px;
        height: 19px;
        box-sizing: border-box;
      }
      .abnormal{
        label{
          width: 100px;
        }
      }
      .abnormal-num {
        color: red;
        font-weight: 600;
      }
    }
    .error_num {
      color: #0000FF;
      text-decoration:underline;
    }
    .el-table .info-row {
      background: #FFAEB9;
    }
  }

</style>

<template>
  <div class="customer-service-statistics">
    <search-bar more-display label-width="100px">
      <el-row>
        <el-col :span="8">
          <el-form-item label="订单编号">
            <el-input v-model="searchCondition.LIKE_orderNumber"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="提交日期">
            <el-date-picker
              v-model="submitTimerange"
              type="daterange"
              :picker-options="pickerOptions">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="客户名称">
            <el-input v-model="searchCondition.LIKE_memberUserName"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="订单状态">
            <el-select v-model="searchCondition.EQ_orderStatus">
              <el-option
                v-for="item in $store.getters.ORDER_STATUS"
                :key="item.id"
                :label="item.cnDictValname"
                :value="item.dictVal">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="发货人">
            <el-input v-model="searchCondition.LIKE_shipmentsContactName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="发货人手机">
            <el-input v-model="searchCondition.LIKE_shipmentsContactPhone"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="支付状态">
            <el-select v-model="searchCondition.EQ_payStatus">
              <el-option
                v-for="item in $store.getters.ORDER_PAY_STATUS"
                :key="item.id"
                :label="item.cnDictValname"
                :value="item.dictVal">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="收货人">
            <el-input v-model="searchCondition.LIKE_sendContactName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="收货人手机">
            <el-input v-model="searchCondition.LIKE_sendContactPhone"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="专线组织">
            <el-cascader style="width: 100%"
                         v-model="searchCondition.LIKE_currentSpecialLineIds"
                         :props="{value:'id',label:'name'}"
                         :options="$store.getters.ORGANIZATIONS||[]">
            </el-cascader>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="收货地址">
            <address-select
              v-model="sendAddressSelect" style="width: 100%"></address-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-row>
            <el-col :span="8">
              <el-form-item label="" label-width="40px">
                <el-checkbox v-model="searchConditionExtend.isErrorNum">
                  异常登记
                </el-checkbox>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="" label-width="40px">
                <el-checkbox v-model="searchConditionExtend.isNotDepart">
                  逾期未发车
                </el-checkbox>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="" label-width="40px">
                <el-checkbox v-model="searchConditionExtend.isNotSignOff">
                  逾期未签收
                </el-checkbox>
              </el-form-item>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
    </search-bar>

    <el-col :span="24" style="margin-bottom: 10px">
      <el-button type="primary" @click="exportData">导出</el-button>
      <el-button type="primary" style="float: right" @click="resetSeachCondition">重置</el-button>
      <el-button type="primary" style="float: right" @click="query">查询</el-button>
    </el-col>

    <el-row :gutter="20" style="margin-bottom: 10px;" class="statics">
      <el-col :span="8">
        <div class="grid-content bg-purple">
          <el-row>
            <el-col :span="12" class="bg-purple-header">订单数量(合计)</el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-row>
                <el-row>
                  <label>订单数：</label>{{orderNum}}票
                </el-row>
                <el-row v-show="receivedShow">
                  <label>已接待：</label>{{alreadyReceivedNum}}票
                </el-row>
                <el-row v-show="receivedShow">
                  <label>已确认：</label>{{alreadyConfirmedNum}}票
                </el-row>
                <el-row v-show="receivedShow">
                  <label>已改单：</label>{{alreadyModifyedNum}}票
                </el-row>
              </el-row>
            </el-col>
            <el-col :span="8" class="abnormal">
              <el-row>
                <el-row>
                  <label>异常登记：</label><span class="abnormal-num">{{orderNumStatistics.orderHaveSignOffError}}</span>票
                </el-row>
                <el-row>
                  <label>逾期未发车：</label><span class="abnormal-num">{{orderNumStatistics.orderAgeingWarningNotDepart}}</span>票
                </el-row>
                <el-row>
                  <label>逾期未签收：</label><span class="abnormal-num">{{orderNumStatistics.orderAgeingWarningNotSignOff}}</span>票
                </el-row>
              </el-row>
            </el-col>
            <el-col :span="8">
              <el-row v-for="(item,index) in orderStatistics.agingDictEntityId" :key="index">
                <label>{{item.dictValName}}：</label>{{item.num}}票
              </el-row>
            </el-col>
          </el-row>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="grid-content bg-purple">
          <el-row>
            <el-col :span="12" class="bg-purple-header">支付情况</el-col>
          </el-row>
          <el-row>
            <el-col :span="12" v-for="(item,index) in orderStatistics.paymentType" :key="index">
              <el-row>
                <label>{{item.dictValName}}：</label>{{item.num}}票
              </el-row>
            </el-col>
            <el-col :span="12">
              <el-row><label>订单总额：</label>￥{{orderPrice.toFixed(2)}}</el-row>
            </el-col>
            <el-col :span="12">
              <el-row><label>已支付：</label>￥{{orderAlreadyPaid.toFixed(2)}}</el-row>
            </el-col>
          </el-row>
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content bg-purple">
          <el-row>
            <el-col :span="12" class="bg-purple-header">签收情况</el-col>
          </el-row>
          <el-row>
            <label>已签收：</label>{{signedNum}}票
          </el-row>
          <el-row>
            <label>到付收款：</label>￥{{signedToPayPrice.toFixed(2)}}
          </el-row>
          <el-row>
            <label>代收收款：</label>￥{{signedCollectPaymentAmount.toFixed(2)}}
          </el-row>
          <el-row>
            <label>异常签收：</label><span class="abnormal-num">{{orderNumStatistics.orderSignOffError}}</span>票
          </el-row>
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content bg-purple">
          <el-row>
            <el-col :span="12" class="bg-purple-header">客户数量</el-col>
          </el-row>
          <el-row>
            <label>新注册：</label>{{orderStatistics.newMebPersonNum}}
          </el-row>
          <el-row>
            <label>客户累计：</label>{{orderStatistics.mebPersonNum}}
          </el-row>
        </div>
      </el-col>
    </el-row>
    <!--列表-->
    <el-table :data="tableData" max-height="480"
              v-loading="listLoading"
              :row-class-name="tableRowClassName"
              highlight-current-row border style="width: 100%;">
      <el-table-column label="订单号" width="200">
        <template slot-scope="scope">
          <el-button type="text" style="padding: 0;" @click="openDialog(scope.row.id,scope.row.orderNumber)">
            {{scope.row.orderNumber}}
          </el-button>
          <div>{{scope.row.freightNumber}}</div>
          <div>{{scope.row.shipmentsRegion}}</div>
          <div>{{scope.row.sendRegion}}</div>
        </template>
      </el-table-column>
      <el-table-column label="计划时间" width="265">
        <template slot-scope="scope">
          <div>提交时间 {{scope.row.submitTime}}</div>
          <div>发运日期 {{scope.row.shipmentsDate}}</div>
          <div v-if="scope.row.extractType === 105002001">
            计划提货 {{scope.row.extractDate}} {{scope.row.extractTime}}
          </div>
          <div v-else>自送网点 &nbsp;&nbsp;{{scope.row.startNetWorkName}}</div>
          <div v-if="scope.row.sendType === 105001001">
            计划送货 {{scope.row.sendTime}}
          </div>
          <div v-else>
            网点自提 &nbsp;&nbsp;{{scope.row.endNetWorkName}}
          </div>
        </template>
      </el-table-column>
      <el-table-column label="货物信息">
        <template slot-scope="scope">
          <div>{{scope.row.cargoNames}}</div>
          <div>{{scope.row.amount}}件</div>
          <div>{{scope.row.weight.toFixed(2)}}吨</div>
          <div>{{scope.row.volume.toFixed(2)}}方</div>
        </template>
      </el-table-column>
      <el-table-column label="订单金额(元)" width="120">
        <template slot-scope="scope">
          <div>{{scope.row.agingName}}</div>
          <div>{{scope.row.paymentTypeName}}</div>
          <div style="color: #ff4949;">{{scope.row.orderPrice}} 元</div>
          <div style="color: #ff4949;">{{scope.row.payStatusName}}</div>
        </template>
      </el-table-column>
      <el-table-column label="发货人信息" width="225">
        <template slot-scope="scope">
          <div>{{scope.row.memberUserName}}</div>
          <div>{{scope.row.shipmentsContactName}}</div>
          <div>{{scope.row.shipmentsContactPhone}} {{scope.row.shipmentsTelephone}}</div>
        </template>
      </el-table-column>
      <el-table-column label="收货人信息" width="225">
        <template slot-scope="scope">
          <div>{{scope.row.sendContactName}}</div>
          <div>{{scope.row.sendContactPhone}} {{scope.row.sendTelephone}}</div>
          <div>{{scope.row.sendStreet}}</div>
        </template>
      </el-table-column>
      <el-table-column label="异常" width="120">
        <template slot-scope="scope">
          <div v-if="scope.row.signOffErrorNum">异常登记: <el-button type="text" class="error_num" style="padding: 0;" @click="openSignOffErrorDialog(scope.row.id,scope.row.orderNumber,scope.row.signOffErrorNum)">
            {{scope.row.signOffErrorNum}}
          </el-button></div>
        </template>
      </el-table-column>
      <el-table-column label="物流状态" width="300">
        <template slot-scope="scope">
          <div style="color: #13ce66">
            <div>{{scope.row.orderStatusName}}</div>
            <div>{{scope.row.trackRemark}}</div>
            <div>{{scope.row.trackTime}}</div>
          </div>
        </template>
      </el-table-column>
    </el-table>

    <!--工具条-->
    <el-col :span="24" class="toolbar">
      <el-pagination
        :current-page="page"
        :page-size="size"
        @size-change="handleSizeChange"
        @current-change="handleCurrentPageChange"
        layout="total,sizes,prev, pager, next, jumper"
        :total="total" style="float: right">
      </el-pagination>
    </el-col>
    <order-track-detail ref="orderTrackDetail"></order-track-detail>
    <sign-off-error-record ref="signOffErrorRecord"></sign-off-error-record>
  </div>
</template>

<script>
import { searchNewOrders, orderStatistics, orderNumStatisticsForFilters } from '../../api/order/orderNew';
import { mebPersonStatistics } from '../../api/meb-user/MebPerson';
import { signOffStatistics, getSignOffErrorByOrderId } from '../../api/stowage/SingIn';
import { receptionTypeStatistics } from '../../api/order/receptionEntering';
import OrderTrackDetail from './OrderTrackDetail.vue';
import SignOffErrorRecord from '../stowage/SignOffErrorRecord.vue';
import { isEmpty } from '../../lib/util';
export default {
  components: {
    OrderTrackDetail,
    SignOffErrorRecord
  },
  data () {
    return {
      receivedShow: true,
      submitTimerange: [new Date(), new Date()],
      sendAddressSelect: [],
      searchConditionExtend: {
        isErrorNum: false,
        isNotDepart: false,
        isNotSignOff: false
      },
      searchCondition: {
        LIKE_currentSpecialLineIds: [],
        LIKE_orderNumber: null,
        LT_submitTime: null,
        GT_submitTime: null,
        LIKE_memberUserName: null,
        EQ_orderStatus: null,
        EQ_payStatus: null,
        LIKE_shipmentsContactName: null,
        LIKE_shipmentsContactPhone: null,
        LIKE_sendContactName: null,
        LIKE_sendContactPhone: null
      },
      orderNumStatistics: {
        orderHaveSignOffError: 0,
        orderSignOffError: 0,
        orderAgeingWarningNotDepart: 0,
        orderAgeingWarningNotSignOff: 0
      },
      orderStatistics: {
        paymentType: [],
        agingDictEntityId: [],
        payStatus: [],
        orderStatus: [],
        signOff: [],
        mebPersonNum: 0,
        newMebPersonNum: 0,
        receptionType: []
      },
      pickerOptions: {
        shortcuts: [{
          text: '今日',
          onClick (picker) {
            picker.$emit('pick', picker.$ue.getToday());
          }
        }, {
          text: '本周',
          onClick (picker) {
            picker.$emit('pick', picker.$ue.getThisWeek());
          }
        }, {
          text: '本月',
          onClick (picker) {
            picker.$emit('pick', picker.$ue.getThisMonth());
          }
        }]
      },
      tableData: [],
      total: 0,
      page: 1,
      size: 10,
      listLoading: false
    };
  },
  computed: {
    signedNum () {
      return this.orderStatistics.signOff
        .reduce((previous, current, index, array) => {
          return previous + current.num;
        }, 0);
    },
    alreadyReceivedNum () {
      return this.orderStatistics.receptionType.filter(o => o.dictVal === 101020007)
        .reduce((previous, current, index, array) => {
          return previous + current.num;
        }, 0);
    },
    alreadyConfirmedNum () {
      return this.orderStatistics.receptionType.filter(o => o.dictVal === 101020002)
        .reduce((previous, current, index, array) => {
          return previous + current.num;
        }, 0);
    },
    alreadyModifyedNum () {
      return this.orderStatistics.receptionType.filter(o => o.dictVal === 101020006)
        .reduce((previous, current, index, array) => {
          return previous + current.num;
        }, 0);
    },
    signedToPayPrice () {
      return this.orderStatistics.signOff.filter(o => o.dictVal === 102002002)
        .reduce((previous, current, index, array) => {
          return previous + current.freightPrice;
        }, 0);
    },
    signedCollectPaymentAmount () {
      return this.orderStatistics.signOff
        .reduce((previous, current, index, array) => {
          return previous + (current.collectPaymentAmount || 0);
        }, 0);
    },
    orderNum: function () {
      return this.orderStatistics.agingDictEntityId.reduce((previous, current, index, array) => {
        return previous + current.num;
      }, 0);
    },
    orderPrice: function () {
      return this.orderStatistics.payStatus.reduce((previous, current, index, array) => {
        return previous + current.price;
      }, 0);
    },
    orderAlreadyPaid: function () {
      return this.orderStatistics.payStatus
        .filter(o => o.dictVal === 101003002)
        .reduce((previous, current, index, array) => {
          return previous + current.price;
        }, 0);
    }
  },
  methods: {
    tableRowClassName (row, index) {
      if (row.signOffErrorNum && row.signOffErrorNum > 0 && row.orderStatus > 101001006) {
        return 'info-row';
      }
      return '';
    },
    openDialog (orderId, orderNumber) {
      this.$refs.orderTrackDetail.show(orderId, orderNumber);
    },
    openSignOffErrorDialog (orderId, orderNumber, errorNum) {
      getSignOffErrorByOrderId({orderId: orderId}).then((res) => {
        this.signOffErrorListData = [];
        if (res.data.successFlg === true && res.data.detailModelList !== null) {
          let list = res.data.detailModelList;
          this.signOffErrorListData = list;
        }
        this.$refs.signOffErrorRecord.show(orderNumber, errorNum, this.signOffErrorListData);
      });
    },
    resetSeachCondition () {
      this.$ue.resetObjNull(this.searchCondition);
      this.submitTimerange = [];
      this.sendAddressSelect = [];
      this.searchConditionExtend = {
        isErrorNum: false,
        isNotDepart: false,
        isNotSignOff: false
      };
    },
    exportData () {
      let ageingFilters = '&isErrorNum=' + this.searchConditionExtend.isErrorNum + '&isNotDepart=' + this.searchConditionExtend.isNotDepart + '&isNotSignOff=' + this.searchConditionExtend.isNotSignOff;
      location.href = '/api/v2.0/admin/orders/export?filters=ISNOTNULL_confirmTime;' + this.$ue.objToFilter(this.searchCondition) + this.addressSelectFilter() + ageingFilters;
    },
    addressSelectFilter () {
      let addressFilters = '';
      let addressSelectLength = this.sendAddressSelect.length;
      if (addressSelectLength > 0) {
        switch (addressSelectLength) {
          case 1:
            addressFilters += ';EQ_sendProvinceId=' + this.sendAddressSelect[0];
            break;
          case 2:
            addressFilters += ';EQ_sendProvinceId=' + this.sendAddressSelect[0] + ';EQ_sendCityId=' + this.sendAddressSelect[1];
            break;
          case 3:
            addressFilters += ';EQ_sendProvinceId=' + this.sendAddressSelect[0] + ';EQ_sendCityId=' + this.sendAddressSelect[1] + ';EQ_sendCountyId=' + this.sendAddressSelect[2];
            break;
        }
      }
      return addressFilters;
    },
    ageingFiltersExtend () {
      let ageingFilters = '';
      if (this.searchConditionExtend.isErrorNum) {
        ageingFilters += ';ISNOTNULL_LEFT_signOff.errorNum;GT_LEFT_signOff.errorNum=0;';
      }
      if (this.searchConditionExtend.isNotDepart) {
        ageingFilters += ';ISNOTNULL_LEFT_ageingWarningNotDepart.id';
      }
      if (this.searchConditionExtend.isNotSignOff) {
        ageingFilters += ';ISNOTNULL_LEFT_ageingWarningNotSignOff.id';
      }
      return ageingFilters;
    },
    query () {
      let sc = Object.assign({}, this.searchCondition);
      if (!isEmpty(sc.LIKE_currentSpecialLineIds)) {
        sc.LIKE_currentSpecialLineIds = sc.LIKE_currentSpecialLineIds[sc.LIKE_currentSpecialLineIds.length - 1];
      }
      let filters = this.$ue.objToFilter(sc);
      this.loadOrders(filters.replace('LIKE_currentSpecialLineIds', 'LIKE_trunkTasks.currentSpecialLineIds') + this.addressSelectFilter() + this.ageingFiltersExtend());
      this.loadOrderStatistics('ISNOTNULL_confirmTime;' + filters.replace('LIKE_currentSpecialLineIds', 'LIKE_trunkTasks.currentSpecialLineIds') + this.addressSelectFilter() + this.ageingFiltersExtend());
      this.orderNumStatisticsAgeing('ISNOTNULL_confirmTime;' + filters.replace('LIKE_currentSpecialLineIds', 'LIKE_trunkTasks.currentSpecialLineIds') + this.addressSelectFilter() + this.ageingFiltersExtend());
      let o = {};
      Object.keys(this.searchCondition).forEach(k => {
        let ks = k.split('_');
        if (ks[1] === 'currentSpecialLineIds' && !isEmpty(this.searchCondition[k])) {
          o[ks[0] + '_order.trunkTasks.' + ks[1]] = this.searchCondition[k][this.searchCondition[k].length - 1];
        } else {
          o[ks[0] + '_order.' + ks[1]] = this.searchCondition[k];
        }
      });
      this.loadMebPersonStatistics(this.$ue.objToFilter({
        GT_createDate: this.searchCondition.GT_submitTime,
        LT_createDate: this.searchCondition.LT_submitTime
      }));
      this.loadSignOffStatistics('ISNOTNULL_order.confirmTime;' + this.$ue.objToFilter(o) + this.addressSelectFilter());
      this.loadReceptionTypeStatistics('ISNOTNULL_order.confirmTime;' + this.$ue.objToFilter(o));
    },
    handleSizeChange (size) {
      this.size = size;
      // this.loadOrders(this.$ue.objToFilter(this.searchCondition).replace('LIKE_currentSpecialLineIds', 'LIKE_trunkTasks.currentSpecialLineIds'));
      this.query();
    },
    handleCurrentPageChange (page) {
      this.page = page;
      // this.loadOrders(this.$ue.objToFilter(this.searchCondition).replace('LIKE_currentSpecialLineIds', 'LIKE_trunkTasks.currentSpecialLineIds'));
      this.query();
    },
    loadOrderStatistics (filters = '') {
      orderStatistics({
        filters: filters
      }).then(res => {
        if (res.data.successFlg) {
          this.orderStatistics.paymentType = res.data.obj.paymentType;
          this.orderStatistics.agingDictEntityId = res.data.obj.agingDictEntityId;
          this.orderStatistics.payStatus = res.data.obj.payStatus;
          this.orderStatistics.orderStatus = res.data.obj.orderStatus;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    },
    orderNumStatisticsAgeing (filters = '') {
      orderNumStatisticsForFilters({
        filters: filters
      }).then(res => {
        if (res.data.successFlg) {
          this.orderNumStatistics.orderHaveSignOffError = res.data.obj.orderHaveSignOffError;
          this.orderNumStatistics.orderSignOffError = res.data.obj.orderSignOffError;
          this.orderNumStatistics.orderAgeingWarningNotDepart = res.data.obj.orderAgeingWarningNotDepart;
          this.orderNumStatistics.orderAgeingWarningNotSignOff = res.data.obj.orderAgeingWarningNotSignOff;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    },
    loadMebPersonStatistics (filters = '') {
      mebPersonStatistics({
        filters: filters
      }).then(res => {
        if (res.data.successFlg) {
          this.orderStatistics.newMebPersonNum = res.data.obj;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
      mebPersonStatistics({
        filters: ''
      }).then(res => {
        if (res.data.successFlg) {
          this.orderStatistics.mebPersonNum = res.data.obj;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    },
    loadReceptionTypeStatistics (filters = '') {
      let receptionAddress = '';
      let addressSelectLength = this.sendAddressSelect.length;
      if (addressSelectLength > 0) {
        switch (addressSelectLength) {
          case 1:
            receptionAddress += ';EQ_LEFT_order.sendProvinceId=' + this.sendAddressSelect[0];
            break;
          case 2:
            receptionAddress += ';EQ_LEFT_order.sendProvinceId=' + this.sendAddressSelect[0] + ';EQ_LEFT_order.sendCityId=' + this.sendAddressSelect[1];
            break;
          case 3:
            receptionAddress += ';EQ_LEFT_order.sendProvinceId=' + this.sendAddressSelect[0] + ';EQ_LEFT_order.sendCityId=' + this.sendAddressSelect[1] + ';EQ_LEFT_order.sendCountyId=' + this.sendAddressSelect[2];
            break;
        }
      }
      receptionTypeStatistics({
        filters: filters + receptionAddress
      }).then(res => {
        if (res.data.successFlg) {
          this.orderStatistics.receptionType = res.data.detailModelList;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    },
    loadSignOffStatistics (filters = '') {
      if (this.searchConditionExtend.isErrorNum) {
        filters += ';ISNOTNULL_errorNum;GT_errorNum=0;';
      }
      if (this.searchConditionExtend.isNotDepart) {
        filters += ';ISNOTNULL_LEFT_ageingWarningNotDepart.id';
      }
      if (this.searchConditionExtend.isNotSignOff) {
        filters += ';ISNOTNULL_LEFT_ageingWarningNotSignOff.id';
      }
      signOffStatistics({
        filters: filters
      }).then(res => {
        if (res.data.successFlg) {
          this.orderStatistics.signOff = res.data.detailModelList;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    },
    loadOrders (filters = '') {
      this.listLoading = true;
      searchNewOrders({
        filters: 'ISNOTNULL_confirmTime;' + filters,
        sorts: '+createDate',
        page: this.page,
        size: this.size
      }).then(res => {
        this.listLoading = false;
        if (res.data.successFlg) {
          this.tableData = res.data.detailModelList;
          this.total = res.data.totalCount;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    }
  },
  watch: {
    submitTimerange (val) {
      if (val && val.length > 0) {
        if (val[0] !== null) {
          this.searchCondition.GT_submitTime = val[0].toJSON();
        }
        if (val[1] !== null) {
          let days = this.$ue.addDays(val[1], 1);
          this.searchCondition.LT_submitTime = days.toJSON();
        }
      } else {
        this.searchCondition.GT_submitTime = null;
        this.searchCondition.LT_submitTime = null;
      }
    },
    'searchConditionExtend': {
      handler (val) {
        if (val.isErrorNum || val.isNotDepart || val.isNotSignOff) {
          this.receivedShow = false;
        } else {
          this.receivedShow = true;
        }
      },
      deep: 1
    }
  },
  mounted () {
    let days = this.$ue.getToday();
    this.searchCondition.GT_submitTime = days[0].toJSON();
    let endDay = this.$ue.addDays(days[1], 1);
    this.searchCondition.LT_submitTime = endDay.toJSON();
    this.$store.commit('initDict');
    this.$store.commit('initOrganizations');
    this.query();
  }
};
</script>
